package cumt.kydd.authoringplatform.controller;

import com.alibaba.fastjson.JSONObject;
import cumt.kydd.authoringplatform.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

import static cumt.kydd.authoringplatform.service.UserService.LoginInUser;

@Controller
public class UserInfoDisplayController {
    @Resource
    private UserService userService;

    @ResponseBody
    @PostMapping("userInfo")
    public String DisplayAllInfo(@RequestParam(required = false) String portrait, String info_email, String info_org, String info_profile, String info_name,String info_tel) {
        info_email = userService.sendInfoEmail(info_email);
        info_org = userService.sendInfoOrg(info_org);
        info_profile = userService.sendInfoProfile(info_profile);
        info_name = LoginInUser.getName();
        info_tel = userService.sendInfoTel(info_tel);
        portrait = userService.sendPortrait(portrait);
//        System.out.println("这是contoller的portrait"+portrait);

        JSONObject result = new JSONObject();
        result.put("email",info_email);
        result.put("org",info_org);
        result.put("profile",info_profile);
        result.put("por",portrait);
        result.put("name",info_name);
        result.put("tel",info_tel);
        return result.toJSONString();
    }
}
